package com.yx.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yx.entity.Address;
import com.yx.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Classname AddressController
 * @Date 2021/07/19 21:55
 * @Author by yx
 * @Description TODO:
 */
@RestController
@RequestMapping("/addressController")
public class AddressController {
    @Autowired
    private IAddressService addressService;

    @RequestMapping("/getAddressListByUid/{uid}")
    public List<Address> getAddressListByUid(@PathVariable Integer uid){
        QueryWrapper<Address> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", uid);
        return addressService.list(queryWrapper);
    }

    @RequestMapping("/save")
    public Boolean save(@RequestBody Address address){
        return addressService.save(address);
    }

    @RequestMapping("/getAddressByid/{id}")
    public Address getAddressByid(@PathVariable Integer id){
        return addressService.getById(id);
    }
}
